package qs.controls.calendarDisplayClasses
{
	import com.pbsmedia.colagen.assets.AssetLib;
	
	import flash.events.MouseEvent;
	
	import mx.controls.Image;
	import mx.core.UIComponent;
	
	import qs.calendar.CalendarEvent;
	
	public class CalendarEventPopUp extends UIComponent implements ICalendarEventPopUp
	{
		private var _calendarEvent:CalendarEvent;
		private var _commitButt:Image;
		private var _canCommit:Boolean;
		public var doCommit:Function;
		private var _deleteButt:Image;
		public var doDelete:Function;
	
		public var contentsArray:Array = new Array()
		
		public function CalendarEventPopUp()
		{
		
		}

		public function set calendarEvent(ce:CalendarEvent):void
		{
			if(ce != null){
			
			this._calendarEvent = ce;}
		}
		public function get calendarEvent():CalendarEvent{
			return this._calendarEvent;
		}
		public function set canCommit(boo:Boolean):void
		{
			this._canCommit = boo;
			
		}
		public function get canCommit():Boolean{
			return this._canCommit;
		}
		
		
		
		override protected function createChildren():void{
			
			if(canCommit){
			_commitButt = new Image;
			_commitButt.source = AssetLib.applicationPutIcon;
			_commitButt.toolTip = "Commit Event to this room ?";
			_commitButt.addEventListener(MouseEvent.CLICK,doCommit);
			addChild(_commitButt);
			contentsArray.push(_commitButt);
			}
			
			_deleteButt = new Image;
			_deleteButt.source = AssetLib.deleteIcon;
			_deleteButt.toolTip = "Delete this Event ?";
			_deleteButt.addEventListener(MouseEvent.CLICK,doDelete);
			addChild(_deleteButt);
			contentsArray.push(_deleteButt);
			
		
			
			
			
		}
		override protected function measure():void{
			measuredWidth =  _deleteButt.measuredWidth;
			measuredHeight  = _deleteButt.measuredHeight*contentsArray.length;
			
		}
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
			
			graphics.lineStyle(1,0xAAAADD);
			
			graphics.drawRect(0, 0,unscaledWidth,unscaledHeight);
			
			
			_deleteButt.setActualSize(16,16);
			_deleteButt.move(0,0);
			if(_commitButt != null){
			_commitButt.setActualSize(16,16);
			_commitButt.move(0,_deleteButt.measuredHeight);}
			
		}
		
		
		
		
	}
}